﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;


using CRM.Entity;
using CRM.Entity.Extra;
using CRM.Dictionary.Service;
using CRM.DataAccess;
using CRM.Entity.Page;

namespace CRM.DataService
{
    public partial class Sys_UserInfo_DataService
    {
        //对Dictionary的操作类
        Sys_UserInfo_DicService dicService;
        //对数据层的操作类
        Sys_UserInfo_DataAccess dataAccess;

        public Sys_UserInfo_DataService()
        {
            dicService = new Sys_UserInfo_DicService();

            dataAccess = new Sys_UserInfo_DataAccess();
        }

        public List<Sys_UserInfo> GetAll()
        {
            return dicService.Sys_UserInfo_List().ListEntity;
        }

        public Sys_UserInfoPage GetList(PageInfo page)
        {
            return dicService.Sys_UserInfo_List(page);
        }

        public Sys_UserInfoPage GetList(Func<Sys_UserInfo, bool> func)
        {
            return dicService.Sys_UserInfo_List(func);
        }

        public Sys_UserInfoPage GetList(PageInfo page, Func<Sys_UserInfo, bool> func)
        {
            return dicService.Sys_UserInfo_List(page, func);
        }

        public List<Sys_UserInfo> GetListTop(int top, Func<Sys_UserInfo, bool> func)
        {
            return dicService.Sys_UserInfo_List_Top(top, func);
        }

        public Sys_UserInfo GetSingle(int Sys_UserInfoID)
        {
            return dicService.Sys_UserInfo_Single(Sys_UserInfoID);
        }

        public Sys_UserInfo GetSingleMultiple(Func<Sys_UserInfo, bool> func)
        {
            return dicService.Sys_UserInfo_Multiple(func);
        }

        public bool Add(Sys_UserInfo sys_UserInfo)
        {            
            //先插入数据库
            bool isSuccess = dataAccess.Sys_UserInfo_Add(sys_UserInfo);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再插入内存
            isSuccess = dicService.Sys_UserInfo_Add(sys_UserInfo);

            return isSuccess;
        }
        
        public bool AddBatch(List<Sys_UserInfo> list)
        {            
            //先插入数据库
            bool isSuccess = dataAccess.Sys_UserInfo_AddBatch(list);
            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再插入内存
            isSuccess = dicService.Sys_UserInfo_AddBatch(list);

            return isSuccess;
        }

        public bool Update(Sys_UserInfo sys_UserInfo)
        { 
            //先更新数据库
            bool isSuccess = dataAccess.Sys_UserInfo_Update(sys_UserInfo);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再更新内存
            isSuccess = dicService.Sys_UserInfo_Update(sys_UserInfo);

            return isSuccess;
        }
        
        public bool UpdateBatch(List<Sys_UserInfo> list)
        {
            //先更新数据库
            bool isSuccess = dataAccess.Sys_UserInfo_UpdateBatch(list);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再更新内存
            isSuccess = dicService.Sys_UserInfo_UpdateBatch(list);

            return isSuccess;
        }

        public bool Delete(Sys_UserInfo sys_UserInfo)
        {     
            //先删除数据库
            bool isSuccess = dataAccess.Sys_UserInfo_Remove(sys_UserInfo);

            //插入失败
            if (!isSuccess)
                return isSuccess;

            //再删除内存
            isSuccess = dicService.Sys_UserInfo_Remove(sys_UserInfo);

            return isSuccess;
        }
    }
}





